<?php
class Categories {
	function viewAll() {
		$query = "select * from dt_categories";
		$data = mysql_query($query);
		return $data;
	}
	
	function viewAllCtg() {
		$query = "select * from dt_categories where c_parent_id = '0'";
		$data = mysql_query($query);
		return $data;
	}
	
	function viewAllSCtg($id) {
		$query = "select * from dt_categories where c_parent_id = '$id'";
		$data = mysql_query($query);
		return $data;
	}
	
	function selectSingle($id) {
		$query = "select * from dt_categories where c_id = '$id'";
		$data = mysql_query($query);
		return $data;
	}
	
	function update($title, $desc, $pid, $visible, $id, $meta_desc, $meta_keys, $meta_title) {
		$query = "update dt_categories set c_title = '$title', c_desc = '$desc', c_parent_id = '$pid', c_visible = '$visible', c_meta_desc = '$meta_desc', c_meta_keys = '$meta_keys', c_meta_title = '$meta_title' where c_id = '$id'";
		mysql_query($query);
	}
	
	function insert($title, $desc, $pid, $visible, $meta_desc, $meta_keys, $meta_title) {
		$query = "insert into dt_categories (c_title, c_desc, c_parent_id, c_visible, c_meta_desc, c_meta_keys, c_meta_title) VALUES ('$title', '$desc', '$pid', '$visible', '$meta_desc', '$meta_keys', '$meta_title')";
		mysql_query($query);
	}
	
	function delete($id) {
		$query = "delete from dt_categories where c_id = '$id'";
		mysql_query($query);
	}
}
?>